<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>ES9反向引用命名捕获</title>
    <script>
        let reg = /^(?<Strive>welcome)-\k<Strive>$/;
        let reg2 = /^(?<Strive>welcome)-\k<Strive>-\1$/;
        let str = 'a-a';
        let str2 = 'Strive-Strive';
        let str3 = 'welcome-welcome';
        let str4 = 'welcome-welcome-welcome';

        console.log(reg.test(str)); //false
        console.log(reg.test(str2)); //false
        console.log(reg.test(str3)); //true
        console.log(reg2.test(str4)); //true
    </script>
</head>

<body>

</body>

</html>